{
 "cells": [
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": [
    "# Harris 角点检测\n",
    "![title](data/harris_1.png)"
   ],
   "id": "ff31d0fe1bca5a9f"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": [
    "### 基本原理\n",
    "![title](data/harris_2.png)"
   ],
   "id": "8dbf1a02dfc80bcc"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "![title](data/harris_9.png)",
   "id": "3e6d8fec30263f0d"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "![title](data/harris_4.png)",
   "id": "31c32aaa01dcb0e1"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "![title](data/harris_5.png)",
   "id": "597fc3702741c3d4"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "![title](data/harris_6.png)",
   "id": "348d2449372c9d38"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "![title](data/harris_11.png)",
   "id": "b777bdc884ae3974"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": [
    "### cv2.cornerHarris()\n",
    "- img: 数据类型为float32的入图像\n",
    "- blockSize: 角点检测中指定区域的大小\n",
    "- ksize: Sobel求导中使用的窗口大小\n",
    "- k: 取值参数为[0, 04, 0.06]"
   ],
   "id": "6b1650c9e9becefd"
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-20T13:22:18.971835Z",
     "start_time": "2025-09-20T13:22:03.592226Z"
    }
   },
   "cell_type": "code",
   "source": [
    "import cv2\n",
    "import numpy as np\n",
    "\n",
    "img = cv2.imread('data/chessboard.jpg')\n",
    "print(img.shape)\n",
    "gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)\n",
    "dst = cv2.cornerHarris(gray, 2, 3, 0.04)\n",
    "img[dst > 0.01 * dst.max()] = [0, 0, 255]\n",
    "cv2.imshow('img', img)\n",
    "cv2.waitKey(0)\n",
    "cv2.destroyAllWindows()\n",
    "print(dst.shape)"
   ],
   "id": "c2a5433254a45eb1",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(512, 512, 3)\n",
      "(512, 512)\n"
     ]
    }
   ],
   "execution_count": 2
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "e394c9db2304a308"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
